/*
 * @Author: qianmingtian
 * @Date: 2020-07-21 11:36:04
 * @LastEditors: qianmingtian
 * @LastEditTime: 2020-07-21 20:08:19
 * @FilePath: \qianmingtian.github.io\code\JVM\FillHeap.java
 */


import java.util.ArrayList;
import java.util.List;

public class FillHeap {
    static class OOMObject {
        public byte[] placeHolder = new byte[64 * 1024];
    }

    public static void fill(int num) throws InterruptedException {
        List<OOMObject> list = new ArrayList<>();
        for (int i = 0; i < num; i++) {
            Thread.sleep(50);
            list.add(new OOMObject());
            System.out.println("add ");
        }
    }

    public static void main(String[] args) throws InterruptedException {
        fill(1000);
        System.gc();
    }
}/*
  * @Author: qianmingtian
  * 
  * @Date: 2020-07-21 11:36:04
  * 
  * @LastEditors: qianmingtian
  * 
  * @LastEditTime: 2020-07-21 11:36:04
  * 
  * @FilePath: \qianmingtian.github.io\code\JVM\FillHeap.java
  */
